<?php
require_once ('PHPUnit/Framework/TestCase.php');
require_once ('TVB/PWORKS/util/CommonUtil.class.php');

/**
 * Bill He 2009-10-09 13:45
 */
class VideoGetActionTest extends PHPUnit_Framework_TestCase {

	protected function setUp() {
		/**
		 * begin at
		 * "http://pdes.tvb.com/get_video.html?act=view&id=28&unpublish=0";
		 * then click edit button
		 */
		$this->url = "http://pdes.tvb.com/get_video.html?ut=true";
	}

	protected function tearDown() {
		$this->url = NULL;
	}

	public function testGetVideoFromList() {
		$post_data = array (
			'id' => '10',
			'act' => 'view',
			'unpublish' => 0,
			'error_code' => null,
			'tag' => null,
		);
		$ret = CommonUtil::curl_test($this->url, $post_data);
		$real_data = json_decode($ret);
		$err_num = count($real_data);
		if ($err_num == 0) {
			echo "VideoGetActionTest pass!\r\n";
		}

		$this->assertEquals($err_num, 0);
	}

	public function testFailed() {
		$post_data = array (
			'id' => '10',
			'act' => 'view',
			'unpublish' => 0,
			'error_code' => 1001,
		);

		$ret = CommonUtil :: curl_test($this->url, $post_data);

		$real_data = json_decode($ret);

		$err_num = count($real_data);
		if ($err_num > 0) {
			echo "VideoGetActionTest failed!\r\n";
			var_export($real_data);
		}

		$this->assertEquals($err_num, 0);
	}
}
?>
